<?php

namespace App\Http\Controllers\Api\User;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Facades\Services\User\GiRecordService;
use App\Facades\Utils\ValidateParameter;

class GiRecordController extends Controller
{
    public function record(Request $request){
        $rules = [
            'prev_gi' => 'required',
            'next_gi' => 'required'
        ];

        ValidateParameter::validate($request,$rules);

        $data = $request->all();

        GiRecordService::record($data);

        return formatJsonResponse();
    }

    public function update(Request $request){
        $rules = [
            'id' => 'required|exists:gi_records,id',
            'prev_gi' => 'required',
            'next_gi' => 'required'
        ];

        ValidateParameter::validate($request,$rules);

        $data = $request->all();

        GiRecordService::updateTodayRecord($data);

        return formatJsonResponse();
    }
}
